-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CoreDNS rewrite support for external services. #656
Conversation
Signed-off-by: Avi Weit <[email protected]>
Signed-off-by: Avi Weit <[email protected]>
Signed-off-by: Avi Weit <[email protected]>
End to end tests were made with two EKS AWS clusters with three Import CRs:
these CRs had been added and removed during the tests - to ensure coredns configmap is properly updated. It was also tested with two local kind clusters ensuring that coredns is properly updated. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aviweit - thank you for the pull request and adding this feature!
Can you please
- use uppercase
DNS
in function names and fields exposed? - move all DNS related functions into their own file so changes to existing code files are minimized?
- Consider if the use case is best served by
rewrite
,hosts
orfile
CoreDNS plugin?
Thanks!
} | ||
|
||
// DeleteImport removes the listening socket of a previously imported service. | ||
func (m *Manager) DeleteImport(ctx context.Context, name types.NamespacedName) error { | ||
m.logger.Infof("Deleting import '%s/%s'.", name.Namespace, name.Name) | ||
|
||
// delete user service | ||
errs := make([]error, 3) | ||
errs := make([]error, 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I realize it is not part of the new code, but I wonder if using append won't be a cleaner solution instead of assigning specific array entries. Unless, of course, there is a reliance on the specific order even when there are nil errors in the array.
Alternately, this might be better served by errors.Join()
.
@kfirtoledo @orozery - not familiar with this code well enough to say. Please weigh in.
pkg/controlplane/control/manager.go
Outdated
} | ||
} | ||
if data, ok := cm.Data["Corefile"]; ok { | ||
// remove trailing end-of-line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you use the file / hosts plugins there might already be packages for parsing their data (I imagine the pluiin needs it anyway)
pkg/controlplane/control/manager.go
Outdated
return err | ||
} | ||
} | ||
if data, ok := cm.Data["Corefile"]; ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may want to move rewrite parsing into its own package/struct so that the file parsing is not split across these functions as internal implementation
Co-authored-by: Etai Lev Ran <[email protected]> Signed-off-by: Avi Weit <[email protected]>
Co-authored-by: Etai Lev Ran <[email protected]> Signed-off-by: Avi Weit <[email protected]>
Signed-off-by: Avi Weit <[email protected]>
Signed-off-by: Avi Weit <[email protected]>
Signed-off-by: Avi Weit <[email protected]>
Signed-off-by: Avi Weit <[email protected]>
Co-authored-by: Etai Lev Ran <[email protected]> Signed-off-by: Avi Weit <[email protected]>
Co-authored-by: Etai Lev Ran <[email protected]> Signed-off-by: Avi Weit <[email protected]>
Signed-off-by: Avi Weit <[email protected]>
@aviweit can you give examples of aliases (those you set in |
Signed-off-by: Avi Weit <[email protected]>
The PR is set with the discussed changes. It was tested with kind and AWS EKS clusters. Thanks. |
I have tested this PR with two kind clusters using various
I have also tested with two AWS EKS clusters in respect to internal service (e.g. incluster nginx-project) and external ones e.g. AWS s3, AWS lambda. The policies being used for all tests where "allow all". |
pkg/controlplane/control/dns.go
Outdated
return err | ||
} | ||
} | ||
if data, ok := cm.Data["Corefile"]; ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a CoreDNS package to parse and edit Corefile instead of manually manipulating string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems there is. I found a blog on this:
https://medium.com/jamf-engineering/mastering-coredns-configuration-parsing-the-corefile-with-go-reflection-9180f121a69
Signed-off-by: Avi Weit <[email protected]>
Signed-off-by: Avi Weit <[email protected]>
Signed-off-by: Avi Weit <[email protected]>
Signed-off-by: Avi Weit <[email protected]>
Signed-off-by: Avi Weit <[email protected]>
Signed-off-by: Avi Weit <[email protected]>
@aviweit - thank you for this contribution - we're looking for the the best way to make it available in ClusterLink, safely. Thus, I'm marking it as The main concern is that The maintainers will follow up on this work to address the above concern and allow users to experiment with it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orozery @kfirtoledo need to figure out how to enable this functionality while giving administrators control over what can be aliased without negatively affecting entire cluster or "escaping" from the import's namespace
@aviweit - thank you for the feature enhancement proposal and PR work that accompanied it. At this point, we feel that using Import aliases (a namespace scoped construct) to affect CoreDNS configuration (a cluster wide resource, typically under tight administrative control) would not be something we can maintain securely over the long run. Thus, I will close the current PR. We are exploring alternative ways to support this. One possible approach might be adding a per namespace DNS server to provide aliases (which could be based on CoreDNS and the Thank you again for the PR! |
This PR deals with updating CoreDNS configuration to rewrite/resolve external names as described in issue #26.
Fixes #26